export default class CustomPalette {
	constructor(create, elementFactory, palette) {
		this.create = create
		this.elementFactory = elementFactory
		this.palette = palette

		palette.registerProvider(this)
	}
	// 这个函数就是绘制palette的核心
	getPaletteEntries(element) {
		const elementFactory = this.elementFactory
		const create = this.create

		function createTask(type) {
			return function(event) {
				
				const sequenceFlow = elementFactory.create('shape', {
					type: 'bpmn:ExclusiveGateway'
				})
				// console.log('elementFactory', elementFactory)
				const businessObject = elementFactory.create('shape', {
					type: type
					// outgoing: [sequenceFlow]
				})
				console.log('???', businessObject)
				create.start(event, businessObject)
			}
		}

		return {
			'create.lindaidai-task': {
				group: 'model', // 分组名
				className: 'bpmn-icon-task red', // 样式类名
				title: '创建一个类型为lindaidai-task的任务节点',
				action: { // 操作
					dragstart: createTask('bpmn:UserTask'), // 开始拖拽时调用的事件
					click: createTask('bpmn:UserTask') // 点击时调用的事件
				}
			}
		}
	}


}

CustomPalette.$inject = [
	'create',
	'elementFactory',
	'palette'
]
